package org.example.sword2offer.primary;

/**
 * @author: lynn
 * @Descript: 斐波那契数列  f(n) = f(n-1) + f(n-2)
 * * Question 8
 * @date: 2021/3/8 22:07
 * @version: 1.0
 */
public class Q8_FibonacciNum {

    public static void main(String[] args) {
        System.out.println(Fibonacci(6));
    }
    private static int Fibonacci(int n){
        if (n<0){
            throw new IllegalArgumentException("输入参数非法！");
        }
        if (n<=1){
            return n;
        }
        return Fibonacci(n-1)+Fibonacci(n-2);
    }

}
